import request from '@/utils/request'

function getToken() {
  return localStorage.getItem('business-token')
}

// 获取渠道列表（列表用）
export const getChannelList = data => {
  return request('/hzsx/channel/queryBackstageChannelPage', {
    method: 'POST',
    headers: {
      token: getToken()
    },
    data
  })
}

// 获取渠道列表（下拉用）
export const getCountChannelList = () => {
  return request('/hzsx/channel/channelList', {
    method: 'GET',
    headers: {
      token: getToken()
    }
  })
}

// 添加渠道
export const addChannel = data => {
  return request('/hzsx/channel/addBackstageChannel', {
    method: 'POST',
    headers: {
      token: getToken()
    },
    data
  })
}
// 修改渠道
export const editChannel = data => {
  return request('/hzsx/channel/updateBackstageChannel', {
    method: 'POST',
    headers: {
      token: getToken()
    },
    data
  })
}
// 删除渠道列表
export const delChannelById = id => {
  return request(`/hzsx/channel/delete?id=${id}`, {
    method: 'GET',
    headers: {
      token: getToken()
    }
  })
}
// 渠道启用禁用
export const updateChannelConfigState = data => {
  return request('/hzsx/channel/updateChannelConfigState', {
    method: 'POST',
    headers: {
      token: getToken()
    },
    data
  })
}
// 更新渠道链接
export const updateChannelPath = data => {
  return request('/hzsx/channel/updateChannelPath', {
    method: 'POST',
    headers: {
      token: getToken()
    },
    data
  })
}
// 检查渠道编码是否重复
export const isRepeatCode = channelCode => {
  return request('/hzsx/channel/checkChannelCode', {
    method: 'GET',
    params: {
      channelCode
    },
    headers: {
      token: getToken()
    }
  })
}

// 渠道统计
export const getChannelCount = data => {
  return request('/hzsx/channel/countBackstageChannel', {
    method: 'POST',
    data,
    headers: {
      token: getToken()
    }
  })
}

// 渠道会员列表
export const getChannelUserList = data => {
  return request('/hzsx/channel/getChannelUserList', {
    method: 'POST',
    data,
    headers: {
      token: getToken()
    }
  })
}
// 用户绑卡列表
export const getUserBankList = data => {
  return request(`/hzsx/user/userBankList?uid=${data}`, {
    method: 'GET',
    data:data,
    headers: {
      token: getToken()
    }
  })
}
// 用户解绑
export const getCancelUserBank = data => {
  return request('/hzsx/user/cancelUserBank', {
    method: 'POST',
    data,
    headers: {
      token: getToken()
    }
  })
}
// 数据统计---会员列表
export const getQueryUserListBaseInfo = data => {
  return request('/hzsx/user/queryUserListBaseInfo', {
    method: 'POST',
    data,
    headers: {
      token: getToken()
    }
  })
}
